package com.wdcloud.framework_business.base;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.wdcloud.framework_business.R;
import com.wdcloud.framework_business.mvp.IBasePresenter;
import com.wdcloud.framework_business.mvp.IBaseView;

public abstract class BaseActivity<T extends IBasePresenter>extends BaseBusinessActivity implements IBaseView {

    protected T mPresenter;

    @SuppressWarnings("unchecked")
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        mPresenter = initPresenter();
        if (mPresenter != null) {
            mPresenter.attachView(this);
        }
        super.onCreate(savedInstanceState);
    }
    @Override
    protected void onDestroy() {
        if (mPresenter != null) {
            mPresenter.detachView();
        }
        super.onDestroy();
    }


    protected abstract T initPresenter();
}